package river_city_ransom.contracts;

import exceptions.ComposantError;
import exceptions.PostconditionError;
import exceptions.PreconditionError;
import river_city_ransom.services.Dimensions;
import river_city_ransom.services.Gangster;
import river_city_ransom.services.Position;
import tools.Toolbox;


public class Gangster_C extends Personnage_C implements Gangster {
	public Gangster_C(Gangster delegate) {
		super(delegate);
	}
	
	@Override
	protected Gangster delegate() {
		return (Gangster) super.delegate();
	}
	
	/** __________________________________________________________ INVARIANTS */
	public void checkInvariants() throws ComposantError {
		super.checkInvariants();
	}
	
	/** ________________________________________________________ CONSTRUCTORS */
	@Override
	public void init(String n, Dimensions d, int f, int pv) throws ComposantError {
		boolean pre;
//		pre init(n, d, f, pv) require n != "" ^ d != NULL ^ f > 0 ^ pv > 0
		pre = !Toolbox.equals(n, "") && d != null && f > 0 && pv > 0;
		if(!pre) {
			throw new PreconditionError("init(n, d, f, pv) require n != \"\" ^ d != NULL ^ f > 0 ^ pv > 0");
		}
		
		delegate().init(n, d, f, pv);
		
		checkInvariants();
		
		boolean post;
//		post nom(init(n, d, f, pv)) = n
		post = Toolbox.equals(nom(), n);
		if(!post) {
			throw new PostconditionError("nom(init(n, d, f, pv)) = n");
		}
//		post dimensions(init(n, d, f, pv)) = d
		post = Toolbox.equals(dimensions(), d);
		if(!post) {
			throw new PostconditionError("dimensions(init(n, d, f, pv)) = d");
		}
//		post estPorte(init(n, d, f, pv)) = false
		post = estPorte() == false;
		if(!post) {
			throw new PostconditionError("estPorte(init(n, d, f, pv)) = false");
		}
//		post estJete(init(n, d, f, pv)) = 0
		post = estJete() == 0;
		if(!post) {
			throw new PostconditionError("estJete(init(n, d, f, pv)) = 0");
		}
//		post force(init(n, d, f, pv)) = f
		post = force() == f;
		if(!post) {
			throw new PostconditionError("force(init(n, d, f, pv)) = f");
		}
//		post maxPointsDeVie(init(n, d, f, pv)) = pv
		post = maxPointsDeVie() == pv;
		if(!post) {
			throw new PostconditionError("maxPointsDeVie(init(n, d, f, pv)) = pv");
		}
//		post pointsDeVie(init(n, d, f, pv)) = pv
		post = pointsDeVie() == pv;
		if(!post) {
			throw new PostconditionError("pointsDeVie(init(n, d, f, pv)) = pv");
		}
//		post choseEquipee(init(n, d, f, pv)) = NULL
		post = choseEquipee() == null;
		if(!post) {
			throw new PostconditionError("choseEquipee(init(n, d, f, pv)) = NULL");
		}
//		post position(init(n, d, f, pv)) = Position::init(0, 0, 0)
		Position p_init = position();
		p_init.init(0, 0, 0);
		post = Toolbox.equals(position(), p_init);
		if(!post) {
			throw new PostconditionError("position(init(n, d, f, pv)) = Position::init(0, 0, 0)");
		}
//		post versLaDroite(init(n, d, f, pv)) = false
		post = versLaDroite() == false;
		if(!post) {
			throw new PostconditionError("versLaDroite(init(n, d, f, pv)) = false");
		}
//		post estGele(init(n, d, f, pv)) = 0
		post = estGele() == 0;
		if(!post) {
			throw new PostconditionError("estGele(init(n, d, f, pv)) = 0");
		}
	}
}
